import { getCustomRoute } from '@/services/customRoute'

const customRouteModel = {
    //dispatch用来分发数据，用namespace，不用customRouteModel
    namespace: 'customRoute',
    //输出菜单数据
    state: {
        customRouteData: {},
    },

    //异步方法
    effects: {
        //定义名字getCustomRoute，在basiclayout中用到
        //call调用service的
        * getCustomRoute({ payload }, { call, put }) {
            const response = yield call(getCustomRoute, payload);
            yield put({
                type: 'show',
                payload: response
            })
        }
    },

    //同步，要改变state的值只能在reducers
    reducers: {
        show(state, action) {
            return {
                ...state,
                customRouteData: action.payload,
            };

        },
    },
}

export default customRouteModel;